(:
  A procedure to select the contents of the 2nd worksheet in excel
:)
declare boundary-space strip;
import module namespace
    jj = "http://kumquat.emse.fr/utilitaires"
    at "jjutils.xq" ;
    
declare namespace xcl = "urn:schemas-microsoft-com:office:spreadsheet";

declare function local:get-timestamp($datecell as node(),$timetype as xs:string) as xs:integer
{
let $time := xs:time(string($datecell))
let $date := fn:dateTime(xs:date('2006-08-15'),$time)
return 
jj:date-to-millis($date)
};

<display>{
let $t := $arguments[1]
let $d := doc($t)/xcl:Workbook/xcl:Worksheet[position()=1]
let $rows := $d/xcl:Table/xcl:Row[position()>1]

for $row at $p in $rows
		let $adjdate := xs:integer(fn:round(xs:float($row/xcl:Cell[1])))
		let $duration := fn:round(xs:float($row/xcl:Cell[3])*1000)
    let $time := jj:date-to-millis(xs:dateTime("1970-01-01T00:00:00")+$adjdate)
		let $millis := $time
		return
	  <item>{
    		<info name="time"><time><date>{$millis}</date><duration>{$duration}</duration></time></info>,
    		<info name="src-anchor">{
      		<anchor>{
        		<doc>{ $t }</doc>,
        		<path>{jj:build-Path($row)}</path>
      	  }</anchor>
    		}</info>,
    		<info name="design_actitivty">{string($row/xcl:Cell[4])}</info>
    		,
    		<info name="usage_vs_tech">{string($row/xcl:Cell[5])}</info>
    		}</item>
}</display>
